package com.ruoyi.wechat.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.CImage;
import com.ruoyi.wechat.domain.OnlineService;
import com.ruoyi.wechat.service.IOnlineServiceService;
import com.ruoyi.wechat.service.impl.OnlineServiceServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/vue/service")
public class VueLiaotian {

    @Autowired
    private IOnlineServiceService onlineServiceService;
    @GetMapping("/list")
    public AjaxResult list( OnlineService onlineService)
    {
//        System.out.println("onlineService:"+onlineService);
        List<OnlineService> onlineServices = onlineServiceService.selectOnlineServiceList1(onlineService);
//        System.out.println("wwwwwwwwwwww:"+onlineServices);
        System.out.println(onlineServices.size());
        for (int i = 0; i < onlineServices.size(); i++) {
//            System.out.println("listmessage:"+onlineServices.get(i));
if (onlineServices.get(i).getSenderId().equals("1")){
    onlineServices.remove(i);
}

//if (onlineServices.get(i).getCampUser().getUsername().equals("")){}

        }
//        System.out.println(onlineServices);
        System.out.println("listmessage:"+onlineServices);
        return AjaxResult.success(onlineServices);
    }



    /**
     * 查询在线客服消息表列表
     */
    @GetMapping("/message/{messageId}")
    public AjaxResult list(@PathVariable("messageId") String userId)
    {

        System.out.println("userId:"+userId);
        List<OnlineService> list = onlineServiceService.selectOnlineServiceListByUserId1(userId);
//        System.out.println("list1111111111111:"+list);
        for (OnlineService onlineService : list){
            System.out.println(onlineService.getContent());
        }





        return AjaxResult.success(list);
    }

}
